SDK-363: Add edge.stats via HTTP Relay channel for device metrics#352
Draft
asafn-ctera wants to merge 1 commit into
Draft
SDK-363: Add edge.stats via HTTP Relay channel for device metrics#352asafn-ctera wants to merge 1 commit into
asafn-ctera wants to merge 1 commit into
Conversation
After filer firmware upgrades, the device-side metrics API (gw-api-handler) requires cookie-based session auth (_cteraSessionId_). The existing binary API channel (/devicecmdnew/) cannot carry HTTP headers by design, so auth always fails. This adds a new Stats command class that uses the portal's HTTP Relay channel (/devices/<name>/) — the same tunnel the Device UI uses — which forwards full raw HTTP including cookies end-to-end. - New cterasdk/edge/stats.py: Stats class with get() for all stat types and intervals, lazy SSO-based device authentication via the relay tunnel - Wire relay client in Clients.__init__ with lazy initialization (device name is only available after remote_command populates __dict__) - Expose edge.stats property on the Edge object (None for local edges) - 11 unit tests covering validation, SSO flow, and session reuse Ref: ESC-10493 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
edge.stats.get(stat_type, interval)for fetching device metrics remotely through the portal/devices/<name>/) instead of the Binary API channel (/devicecmdnew/) — the relay forwards full raw HTTP including cookies, which the device-sidegw-api-handlerrequires for auth after firmware upgradesedge.remote_access())Changes
cterasdk/edge/stats.pyStatscommand class withget()and lazy SSO-based_ensure_session()cterasdk/edge/__init__.pystatsto__all__cterasdk/objects/synchronous/edge.pyedge.statspropertytests/ut/edge/test_stats.pyBackground
After filer firmware upgrades (ESC-10493), the device metrics API (
gw-api-handler) requires cookie-based session auth (_cteraSessionId_). The SDK was routing requests through the Binary API CTTP channel which serializes requests into a binary struct carrying only method + URI — cookies cannot be represented. The HTTP Relay channel (/devices/<name>/), already used by the Device UI for browser-based remote access, forwards raw HTTP end-to-end including cookies.Usage
Test plan
Ref: SDK-363 | ESC-10493